#include "cardpanel.h"

CardPanel::CardPanel(QWidget *parent) : QWidget(parent)
{
    IsFrontImage = true;
    //要将显示的面板大小设置的和pixmap一样大
    setFixedSize(FrontImage.size());
}

void CardPanel::setPixmap(const QPixmap &pixmap)
{
    FrontImage = pixmap;
    //没次设置图像时重新绘制
    update();
}

QPixmap CardPanel::getPixmap()
{
    return FrontImage;
}

void CardPanel::paintEvent(QPaintEvent *e)
{
    (void) e;
    QPainter*p  = new QPainter();
    if(IsFrontImage)
    {
       p->drawPixmap(rect(),FrontImage);
    }
    else
    {
        p->drawPixmap(rect(),BackImage);
    }

}

void CardPanel::setIsSelected(bool select)
{
    IsSelected = select;
}

bool CardPanel::IsSelecte()
{
    return IsSelected;
}

void CardPanel::setIsOwner(bool owner)
{
    IsOwner = owner;
}

bool CardPanel::getIsOwner()
{
    return IsOwner;
}

void CardPanel::setCard(const Card &card)
{
    this->card = card;
}

Card CardPanel::getCard()
{
    return this->card;
}

void CardPanel::setPlayer( Player *player)
{
    this->player = player;
}

Player *CardPanel::getPlayer()
{
    return player;
}
